﻿@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Index.cshtml";
}

@this.Partial("Index-js")
<script>
    var departmentList = @this.Raw(this.ViewBag.DepartmentListString);
</script>

<div class="topPanel">
    <div class="toolbar">
        <div class="btn-group">
            <a class="btn btn-primary" onclick="$ace.reload()"><span class="glyphicon glyphicon-refresh"></span></a>
        </div>
        <div class="btn-group">
            <button class="btn btn-primary" data-bind="click:Edit,attr:{disabled:!DataTable.SelectedModel()}"><i class="fa fa-pencil-square-o"></i>修改</button>
            <button class="btn btn-primary" data-bind="click:Delete,attr:{disabled:!DataTable.SelectedModel()}"><i class="fa fa-trash-o"></i>删除</button>
            <button class="btn btn-primary" data-bind="click:Add"><i class="fa fa-plus"></i>添加</button>
        </div>

    </div>
    <div class="search">
        <table>
            <tr>
                <td>
                    <div class="input-group">
                        <input id="txt_keyword" type="text" class="form-control" placeholder="名称/编号" style="width: 200px;" data-bind="value:SearchModel().keyword">
                        <span class="input-group-btn">
                            <button id="btn_search" type="button" class="btn  btn-primary" data-bind="click:Search"><i class="fa fa-search"></i></button>
                        </span>
                    </div>
                </td>
            </tr>
        </table>
    </div>
</div>


<div class="table-responsive">
    <table class="table table-hover" data-bind="with:DataTable">
        <thead>
            <tr>
                <th style="width:20px;"></th>
                <th>名称</th>
                <th>部门</th>
                <th>创建时间</th>
            </tr>
        </thead>

        <tbody data-bind="foreach:Models">
            <tr data-bind="click:$parent.SelectRow">
                <td data-bind="text:$parent.GetOrdinal($index())"></td>
                <td data-bind="text:Name"></td>
                <td data-bind="text:$ace.getOptionTextByValue(departmentList,DepartmentId())"></td>
                <td data-bind="dateString:CreationTime"></td>
            </tr>
        </tbody>
    </table>
</div>


@using (Html.Dialog())
{

    <form id="form1">
        <div style="margin-top: 10px; margin-left: 10px; margin-right: 10px;">
            <div style="padding-top: 20px; margin-right: 30px;">
                <table class="form">
                    <tr>
                        <td class="formTitle">名称</td>
                        <td class="formValue">
                            <input id="Name" name="Name" type="text" class="form-control required" placeholder="请输入名称" data-bind="value:Model().Name" />
                        </td>
                    </tr>
                    <tr>
                        <td class="formTitle">部门</td>
                        <td class="formValue">
                            <select id="DepartmentId" name="DepartmentId" class="form-control required" data-bind="value:Model().DepartmentId">
                                @this.SelectOptions(this.ViewBag.DepartmentList)
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <th class="formTitle">显示顺序</th>
                        <td class="formValue">
                            <input id="SortCode" name="SortCode" type="text" class="form-control" placeholder="请输入显示顺序" data-bind="value:Model().SortCode" />
                        </td>
                    </tr>
                </table>
            </div>
        </div>
    </form>


}